package com.project.web.wechat.service.impl.app;

import com.project.web.course.service.impl.common.BaseServiceImpl;
import com.project.web.wechat.mapper.app.WxBizAppConfigMapper;
import com.project.web.wechat.mapper.app.WxBizConfigMapper;
import com.project.web.wechat.model.app.WxBizConfig;
import com.project.web.wechat.service.app.WxBizConfigService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


/**
 * 企业微信配置业务实现类
 *
 * @author wyy
 * @date 2020-06-24
 */
@Service("wxBizConfigServiceImpl")
public class WxBizConfigServiceImpl extends BaseServiceImpl<WxBizConfig, Long> implements WxBizConfigService {

    @Autowired
    private WxBizConfigMapper wxBizConfigMapper;

    @Autowired
    private WxBizAppConfigMapper wxBizAppConfigMapper;

    /**
     * 根据ID删除企业微信配置
     *
     * @param id 主键ID
     * @return
     */
    @Override
    public Boolean deleteById(Long id) {
        // 根据企业微信配置ID删应用配置
        wxBizAppConfigMapper.delByConfigId(id);

        // 根据ID删除企业微信配置
        wxBizConfigMapper.delete(id);
        return true;
    }

    /**
     * 根据企业ID查询企业
     *
     * @param corpId 企业ID
     * @return
     */
    @Override
    public WxBizConfig getByCorpId(String corpId) {
        return wxBizConfigMapper.getByCorpId(corpId);
    }

    /**
     * 查询所有的企业微信配置
     *
     * @return
     */
    @Override
    public List<WxBizConfig> selectListOfApps() {
        return wxBizConfigMapper.selectListOfApps();
    }
}
